import { defineStore } from 'pinia';
import { ref } from 'vue';
import { IPlanInfo } from '../typings';

const initState = {
	school_id: 0,
	title: '',
	start_time: '',
	end_time: '',
	book_ids: [],
	class_id: 0,
	book_List: [],
	status: 0, //0 :'未开始';1: '进行中';2: '暂停';3: 已结束';
};

export const usePlanStore = defineStore(
	'plan',
	() => {
		const planInfo = ref<IPlanInfo>({ ...initState });

		const setPlanInfo = (val: IPlanInfo) => {
			planInfo.value = val;
		};

		const clearPlanInfo = () => {
			planInfo.value = undefined;
		};
		const reset = () => {
			planInfo.value = { ...initState };
		};

		return {
			planInfo,
			setPlanInfo,
			clearPlanInfo,
			reset,
		};
	},
	{
		persist: true,
	},
);
